package com.community.process._1010.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class ProcessOrderNotificationQueueConfig {
    public static final String QUEUE_NAME = "process.order.notify.queue";
    public static final String EXCHANGE_NAME = "order.notify.exchange";
    public static final String ROUTING_KEY = "process.order.notify.routingKey";

    @Bean
    public Queue processOrderNotifyQueue() {
        return new Queue(QUEUE_NAME);
    }

    /**
     * 基于插件 延时队列
     * @return
     */
    @Bean
    public Exchange processOrderNotifyExchange() {
        return new TopicExchange(EXCHANGE_NAME,true,false);
    }

    /**
     * 延时队列绑定交换机
     * @return
     */
    @Bean
    public Binding processOrderNotifyQueueBindingProcessOrderNotifyExchange(){
        return BindingBuilder.bind(processOrderNotifyQueue()).to(processOrderNotifyExchange()).with(ROUTING_KEY).noargs();
    }

    
}
